#ifndef _SOKOBAN_CPLAYER_H_
#define _SOKOBAN_CPLAYER_H_

#include "constants.h"
#include "macro.h"
#include "cboard.h"
#include <stdlib.h>
#include <string>
#include <unordered_set>

namespace sokoban {

class CPlayer
{
  static const std::string DEADEND;

  static int nPushes;

public:
  ///constructor
  CPlayer();

  ///solve a board
  ///\param board instance of sokoban game to solve
  ///\return string with the movements of the player to reach a solution
  std::string PlaceBoxes(const CBoard & board);

private:
  // IDA*
  std::string DLSearch(const CBoard & board, int depth, int depthLimit);

  ///iterative deepening search (pseudocode in Figure 3.18, 3rd Ed. AIMA)
  ///\param board instance of sokoban game to solve
  ///\return string solution
  std::string IDSearch(const CBoard & board);

  ///this implements the concept of pruning duplicate states
  bool isStateKnown( CBoard const & newState );

  ///our "hash-table" with the states already visited
  static std::unordered_set<uint64_t> knownStates;

private:

  unsigned int nDLSearchCalls;

};

/* namepsace sokoban */ }

#endif 
